var t = require;
var e = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
o.AdViewEm = void 0;
var a, i;
(function (t) {
    t[(t.banner = 1)] = "banner";
    t[(t.rewardVedio = 2)] = "rewardVedio";
    t[(t.interstitial = 3)] = "interstitial";
})((a = o.AdViewEm || (o.AdViewEm = {})));
(function (t) {
    t[(t.receive = 0)] = "receive";
})(i || (i = {}));
var n = (function () {
    function t() {
        this.curAdCache = {};
        this.isViewAding = {};
        this.viewAdCount = {};
        this.adWait = {};
        this.haveLastTime = {};
        this.adSuccess = {};
        this.adObj = {};
        this.onceCallBack = {};
        this.devId = "";
        this.idObj = {};
        this.lastTime = 0;
        this.lastLoadInterTime = 0;
        this.firstReceiveAd = !1;
        this.firstInterAd = !1;
    }
    t.prototype.getAdData = function (t, e, o) {
        var i = this;
        console.log("QAndroidAdDo ----------------- 当前广告模式安卓");
        this.haveLastTime[a.interstitial] = Date.now();
        var n = this;
        this.getReceive = function (t) {
            console.log("AdViewAndroid -------------stalkooo------ 激励视频回调" + t);
            n.rewardCallBack(t);
        };
        this.getInster = function (t) {
            console.log("AdViewAndroid -------------stalkooo------ 激励视频回调" + t);
            n.interstitialCallBack(t);
        };
        this.loadReceive = function (t) {
            i.adSuccess[a.rewardVedio] = t;
        };
        this.loadInter = function (t) {
            i.adSuccess[a.interstitial] = t;
        };
        this.callDevId = function (t) {
            if ("" != t) {
                i.devId = t;
                AdView.devId = i.devId;
                console.log("AdViewAndroid ----------------- callDevId 回调设备id", t);
            }
        };
        cc.AndroidAdverting = this;
        this.idObj[a.banner] = t;
        this.idObj[a.rewardVedio] = e;
        this.idObj[a.interstitial] = o;
        this.curAdCache[a.banner] = {
            show: this.showBannerAd.bind(this),
            hide: this.hideBannerAd.bind(this),
            preLoad: this.preLoadBannerAd.bind(this),
            destory: this.destoryBannerAd.bind(this)
        };
        this.curAdCache[a.rewardVedio] = {
            show: this.showRewarVediodAd.bind(this),
            hide: this.hideRewarVediodAd.bind(this),
            preLoad: this.preLoadRewarVediodAd.bind(this),
            destory: this.destoryRewarVediodAd.bind(this),
            isCanPlay: this.canPlayReward.bind(this)
        };
        this.curAdCache[a.interstitial] = {
            show: this.showInterstitial.bind(this),
            hide: this.hideInterstitial.bind(this),
            preLoad: this.preLoadInterstitial.bind(this),
            destory: this.destoryInterstitial.bind(this),
            isCanPlay: this.canPlayInterstitial.bind(this)
        };
        setTimeout(function () {
            i.preLoadBannerAd();
            i.preLoadRewarVediodAd();
            i.preLoadInterstitial();
        }, 5e3);
        return this.curAdCache;
    };
    t.prototype.rewardCallBack = function (t) {
        this.onceCallBack[a.rewardVedio] && this.onceCallBack[a.rewardVedio] && this.onceCallBack[a.rewardVedio](t);
        this.onceCallBack[a.rewardVedio] = null;
    };
    t.prototype.interstitialCallBack = function (t) {
        this.onceCallBack[a.interstitial] && this.onceCallBack[a.interstitial] && this.onceCallBack[a.interstitial](t);
        console.log("关闭掉了插屏广告");
        AdView.isCloseInterAd = !0;
        AdView.lastClickTime = Date.now();
        this.onceCallBack[a.interstitial] = null;
    };
    t.prototype.canPlayReward = function () {
        return !!this.adSuccess[a.rewardVedio];
    };
    t.prototype.canPlayInterstitial = function () {
        return !!this.adSuccess[a.interstitial];
    };
    t.prototype.showBannerAd = function (t) {
        void 0 === t && (t = null);
    };
    t.prototype.doShowBanner = function (t) {
        void 0 === t && (t = null);
    };
    t.prototype.showRewarVediodAd = function (t, e, o) {
        void 0 === t && (t = null);
        this.viewAdCount[a.rewardVedio] = this.getObjCount(this.viewAdCount, a.rewardVedio) + 1;
        this.doShowRewarVediodAd(t, e, o);
    };
    t.prototype.showInterstitial = function (t, e, o) {
        void 0 === t && (t = null);
        this.viewAdCount[a.interstitial] = this.getObjCount(this.viewAdCount, a.interstitial) + 1;
        console.log("开始播放插屏广告++++++++++++++++++++++++++++++++++++++++++");
        AdView.isCloseInterAd = !1;
        this.doShowInterstitial(t, e, o);
        return !0;
    };
    t.prototype.hideBannerAd = function (t) {
        void 0 === t && (t = null);
    };
    t.prototype.hideRewarVediodAd = function (t) {
        void 0 === t && (t = null);
    };
    t.prototype.hideInterstitial = function (t) {
        void 0 === t && (t = null);
    };
    t.prototype.preLoadBannerAd = function (t) {
        void 0 === t && (t = null);
    };
    t.prototype.getObjCount = function (t, e) {
        return t[e] ? t[e] : 0;
    };
    t.prototype.preLoadRewarVediodAd = function (t) {
        void 0 === t && (t = null);
        console.log("激励广告", "预加载");
        if (cc.sys.platform == cc.sys.ANDROID && Date.now() - this.lastTime > 5e3) {
            this.lastTime = Date.now();
            this.firstReceiveAd = !0;
            jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "preloadReceiveAd", "()V");
        }
    };
    t.prototype.doShowRewarVediodAd = function (t, e, o) {
        void 0 === t && (t = null);
        this.onceCallBack[a.rewardVedio] = t;
        cc.sys.platform == cc.sys.ANDROID &&
            jsb.reflection.callStaticMethod(
                "org/cocos2dx/javascript/AppActivity",
                "showReceiveAd",
                "(Ljava/lang/String;Ljava/lang/String;)V",
                e,
                o
            );
    };
    t.prototype.doShowInterstitial = function (t, e, o) {
        void 0 === t && (t = null);
        this.onceCallBack[a.interstitial] = t;
        cc.sys.platform == cc.sys.ANDROID &&
            jsb.reflection.callStaticMethod(
                "org/cocos2dx/javascript/AppActivity",
                "showinterAd",
                "(Ljava/lang/String;Ljava/lang/String;)V",
                e,
                o
            );
    };
    t.prototype.preLoadInterstitial = function (t) {
        void 0 === t && (t = null);
        console.log("插屏广告", "预加载");
        if (cc.sys.platform == cc.sys.ANDROID && Date.now() - this.lastLoadInterTime > 5e3) {
            this.lastLoadInterTime = Date.now();
            this.firstInterAd = !0;
            jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "preloadInterAd", "()V");
        }
    };
    t.prototype.destoryBannerAd = function () {};
    t.prototype.destoryRewarVediodAd = function () {};
    t.prototype.destoryInterstitial = function () {};
    Object.defineProperty(t.prototype, "Plat", {
        get: function () {
            return window.tt;
        },
        enumerable: !1,
        configurable: !0
    });
    t.prototype.viewData = function (t, e) {
        console.log("QTtAdDo ----------------- " + t, e);
    };
    return t;
})();
o.default = n;
